# Importing the libraries
# -*- coding: utf-8 -*-
# @Author : 罗天天
import numpy as np
import pandas as pd
from GBDTModel import GBDTModel


def main():
    dataset = pd.read_excel('../../data/date.xlsx')
    x = dataset.iloc[5:, :].values
    print("======原始输入数据的形状========")
    print(np.array(x).shape)
    x = dataset.iloc[5:,
        [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
         59, 61, 63, 65]].values
    x = [[row[i] for row in x] for i in range(len(x[0]))]
    print("======输入数据的长度========")
    print(np.array(x).shape)

    x=np.array(x)
    x = x[:, 50:300]
    print("输入数据:%s" % x)
    print(np.array(x).shape)

    # 原始机测、手测数据 q值
    mmv = pd.read_excel('../../excelData/q_value.xlsx')
    print("======原始机测、手测数据的形状========")
    print(np.array(mmv).shape)
    first_manual_value = mmv.iloc[1, 1:34].values
    y = first_manual_value
    print("=======输出q形状======")
    print(np.array(y).shape)
    print(y)
    #
    # 模型
    model = GBDTModel
    print("============模型训练=============")
    x = np.array(x)
    max = 0
    inx = 0
    for j in range(count):
        acc = model.train(model, x, y, name, j)
        if max < acc:
            max = acc
            inx = j
    print("最优模型：%s"%(inx))


count = 20
name = "q_"
num_of_index = 1
if __name__ == "__main__":
    main()
